import {request} from "./request";

export function getInfo() {
  return request({
    url:'/info'
  })
}

export function getGoods(){
  return request({
    url: '/goods'
  })
}

export function getRatings(){
  return request({
    url: '/ratings'
  })

}

export function getHomeGoods() {
   return request(
     {
       url:'/goods/pop1',
     }
   )
}

export function getHomeNew() {
  return request(
    {
      url:'/goods/new',
    }
  )
}

export function getHomeSell() {
  return request(
    {
      url:'/goods/sell',
    }
  )
}

export function getDetail(id){
  return request(
    {
      url:'/detail',
      params:{
        id
      }
    }
  )
}

export function getRecommend() {
  return request({
    url:'/recommend'
  })
}

export  class Goods {
  constructor(itemInfo,colums,shopInfo){
    this.title = itemInfo.title
    this.desc = itemInfo.desc
    this.newPrice = itemInfo.newPrice
    this.oldPrice = itemInfo.oldPrice
    this.discount = itemInfo.discount
    this.columns = colums
    this.services = shopInfo.services
    this.realPrice = itemInfo.realPrice
    this.discountBgColor = itemInfo.discountBgColor
  }
}

export class Shop {
  constructor(shopInfo){
    this.logo = shopInfo.shopLogo;
    this.name = shopInfo.name;
    this.fans = shopInfo.cFans;
    this.sells = shopInfo.cSells;
    this.score = shopInfo.score;
    this.goodsCount = shopInfo.cGoods
  }
}

//配套request.js里的方案三
/*
request({
  url:'/home'
}).then(res=>{
  console.log(res);
}).catch(err=>{
  console.log(err);
})*/
